package com.meida.module.bus.provider.handler;

import com.meida.common.base.handler.AdminLoginHandler;
import com.meida.common.base.module.LoginParams;
import com.meida.common.mybatis.model.ResultBody;
import com.meida.module.bus.provider.api.service.SyncOAService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component(value = "pmsOaLoginHandler")
public class PmsOaLoginHandler implements AdminLoginHandler {

    @Autowired
    private SyncOAService syncOAService;

    @Override
    public ResultBody beforLogin(LoginParams loginParams) {
        String username = loginParams.getUsername();
        int i = syncOAService.singleLogin(username);
        if (i == 1) {
            return ResultBody.failed("OA系统登陆失败，请联系IT管理员");
        }
        return ResultBody.ok();
    }

    @Override
    public ResultBody afterLogin(Map<String, Object> map, LoginParams loginParams) {
        return ResultBody.ok();
    }
}
